#include <stdio.h>
#include<assert.h>
#include<string.h>

size_t my_strlen(const char* str)
{
	int i = 0;
	assert(str);
	while (*str++)
	{
		i++;
	}
	return i;
}

char* my_strcpy(char* arr1, const char* arr)
{
	char* ret = arr1;
	while (*arr)
	{
		*arr1++ = *arr++;

	}
	return ret;
}

char* my_strcat(char* arr1, const char* arr)
{
	assert(arr1 && arr);
	char* ret = arr1;
	while (*++arr1)
	{
		;
	}
	while (*arr)
	{
		*arr1++ = *arr++;
	}
	return ret;
}

int my_strcmp(const char* arr1, const char* arr)
{
	do
	{
		if (*arr1 != *arr && (*arr1 != '\0' || *arr != '\0'))
		{
			return (*arr1 - *arr);
		}
		else
			return 0;
	} while (*arr1++ == *arr++ );
}

char*my_strstr(const char* arr1, const char* arr)
{
	char* a1 = arr1;
	char* a = arr;
	char* p = arr1;
	while (*p)
	{
		a1 = p;
		a = arr;
		while (*a1 == *a && *a != '\0' && *a1 != '\0')
		{
			a1++;
			a++;
		}
		if (*a == '\0')
		{
			return (char*)p;
		}
		p++;
	}
	return NULL;

}


int main()
{
	char arr[] = "abcdef";
	char arr1[20] = "vasdaabcdef";
	//int ret = my_strlen(arr);
	//printf("%d\n", ret);
	printf("%s\n", my_strstr(arr1, arr));
	return 0;
}